package com.mcb.autopublish.demos.web.po;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

/**
 * 基础po类
 * @author wsj
 * @since 2020/11/10
 */
@Getter
@Setter
public class BasePo implements Serializable {

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createdOn;

    /**
     * 更新时间
     */
    @TableField(fill =FieldFill.INSERT_UPDATE)
    private Date updatedOn;

    /**
     * 乐观锁
     */
    private Long versionOptimizedLock;

    /**
     * 是否删除
     */
    @TableLogic
    private Integer deleted;

    /**
     * 初始化基础数据
     */
    public void initBaseInfo(){
        Date now = new Date();
        this.createdOn = now;
        this.updatedOn = now;
        this.versionOptimizedLock = 1L;
        this.deleted = 0;
    }
}
